package cn.uikit.demo.vp

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import cn.uikit.demo.databinding.ActivityViewpagerTestBinding
import sivin.uikit.framework.BindingActivity
import sivin.uikit.xviewpager.XFragmentStateAdapter

class ViewPagerTestActivity :
    BindingActivity<ActivityViewpagerTestBinding>(ActivityViewpagerTestBinding::inflate) {

    companion object {
        fun launch(context: Context) {
            val startIntent = Intent(context, ViewPagerTestActivity::class.java)
            context.startActivity(startIntent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.vp2.adapter = object : XFragmentStateAdapter(this) {
            override fun getItemCount(): Int {
                return 10
            }

            override fun createFragment(position: Int): Fragment {
                return RecyclerFragment()
            }
        }
    }
}